package com.lehecai.core.api.credit;

import com.lehecai.core.IntegerBeanLabelItem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zhangzq on 14-9-11.
 */
public class SupportPlatformType extends IntegerBeanLabelItem {

    private static final Logger logger = LoggerFactory.getLogger(SupportPlatformType.class.getName());

    private static List<SupportPlatformType> items = new ArrayList<SupportPlatformType>();
    private static List<SupportPlatformType> queryItems = new ArrayList<SupportPlatformType>();

    protected SupportPlatformType(String name, int value, boolean queryOnly) {
        super(SupportPlatformType.class.getName(), name, value);

        queryItems.add(this);
        if (!queryOnly) {
            items.add(this);
        }
    }

    protected SupportPlatformType(String name, int value) {
        this(name, value, false);
    }

    public static SupportPlatformType getItem(int value){
        try {
            return (SupportPlatformType) SupportPlatformType.getResult(SupportPlatformType.class.getName(), value);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return null;
        }
    }

    public static List<SupportPlatformType> getItems() {
        return items;
    }

    public static List<SupportPlatformType> getItemsForQuery() {
        return queryItems;
    }

    public static final SupportPlatformType ALL = new SupportPlatformType("全部", -1, true);
    public static final SupportPlatformType CREDIT_GOODS_PLATFORM_ALL = new SupportPlatformType("全平台", 1);
    public static final SupportPlatformType CREDIT_GOODS_PLATFORM_MAIN = new SupportPlatformType("仅PC", 2);
    public static final SupportPlatformType CREDIT_GOODS_PLATFORM_MOB = new SupportPlatformType("仅客户端", 3);

}
